﻿<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
  </head>
  <body>
<div style="right:0;position:absolute;"><a href="./home"><img style="width:40px;height:40px;" src="img/home.png" alt="返回主页" /></a></div>
    <h1><%= title %></h1>
<form class="form-horizontal" role="form" action="./submitMyInfo" method="post" enctype="multipart/form-data">
	<div class="form-group">
		<label for="name" class="col-sm-2 control-label">网名</label>
		<div class="col-sm-10">
			<input type="text" class="form-control" name="name" 
				   id="name" placeholder="请输入一个帅气的网名" value="<%= currentUser.name %>"/>
		</div>
	</div>
	<div class="form-group">
		<label for="age" class="col-sm-2 control-label">年纪</label>
		<div class="col-sm-10">
			<input type="number" class="form-control" name="age" 
				   id="age" placeholder="请输入年纪" value="<%= currentUser.age %>"/>
		</div>
	</div>
	<div class="form-group">
		<label for="sex" class="col-sm-2 control-label">性别</label>
		<div class="col-sm-10">
            <select name="sex" id="sex">
                <option value="0">男</option>
                <option value="1">女</option>
                <option value="2">其它</option>
            </select>
		</div>
	</div>
	<div class="form-group">
        <label for="sexFor" class="col-sm-2 control-label">取向</label>
		<div class="col-sm-10">
            <select name="sexFor" id="sexFor">
                <option value="0">男</option>
                <option value="1">女</option>
                <option value="2">通吃</option>
            </select>
		</div>
	</div>
	<div class="form-group">
		<label for="logo" class="col-sm-2 control-label">头像</label>
		<div class="col-sm-10">
			<input type="file" class="form-control" name="logo" 
				   id="logo"/>
		</div>
	</div>
	</br>
	<div class="form-group">
		<div class="col-sm-offset-2 col-sm-10">
			<button type="submit" class="btn btn-default">确认</button>
		</div>
	</div>
</form>
	<div style="display:none;" id="temp1"><%= currentUser.sex %></div>
    <div style="display:none;" id="temp2"><%= currentUser.sexFor %></div>
	<script>
		function setSelected() {
			var a = document.getElementById("sex").children;
            //所获得的元素节点是类数组，故用call绑定执行上下文
            Array.prototype.forEach.call(a, function(item) {
                if(item.value == document.getElementById("temp1").innerHTML){
                    console.log(item.value);
                    item.setAttribute('selected', 'selected');
                    console.log(item);
                }
            });
			var b = document.getElementById("sexFor").children;
            Array.prototype.forEach.call(b, function(item) {
                if(item.value == document.getElementById("temp2").innerHTML){
                    console.log(item.value);
                    item.setAttribute('selected', 'selected');
                    console.log(item);
                }
            });           
		}
		window.onload = setSelected;
	</script>
  </body>
</html>
